package com.pcxm.cm.util;

import java.util.List;

import net.sf.json.JSONArray;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class SfJson {
	private static final Log log = LogFactory.getLog(SfJson.class);
	
	static{
		System.out.println("SF静态快");
	}
	
	
	/**
	 * 对象转JSON字符串
	 * @param list
	 * @return
	 * null 返回[null]  , 空数组返回 [] ,字段为null或者" "也会返回，时间会返回具体参数
	 */
	public static String ListToJson(List list) {
	    
		JSONArray jsonArray =JSONArray.fromObject(list);
        String jsonStr = jsonArray.toString(); 
        log.debug((new StringBuilder()).append("list Json str = ").append(jsonStr).toString());
        return jsonStr;
        
	}
	public static String ObjToJson(Object object) {
		
		JSONArray jsonArray =JSONArray.fromObject(object);
		String jsonStr = jsonArray.toString(); 
		log.debug((new StringBuilder()).append("list Json str = ").append(jsonStr).toString());
		return jsonStr;
		
	}
	
}
